****************************  ONLINE Legalization - Intake Call Results ***************************
clear all
*load data
import excel "/Users/mrjensen/Library/CloudStorage/OneDrive-GeorgiaSouthernUniversity/Gambling/Unified Data/Unified_prob_gamb_dataset.xlsx", sheet("online") firstrow

set scheme plotplain

*xtset
xtset state mon_num_tot

*CSDID
egen gvar=csgvar(online_leg), tvar(mon_num_tot) ivar(state)
tab mon_num_tot gvar

*pop
gen lnpop = ln(pop)

csdid intake_calls pop, ivar(state) time(mon_num_tot) gvar(gvar) vce(cluster state)

estat pretrend

estat all

estat event, window (-12 8)

csdid_plot, title("Intake Helpline Calls")

*population descriptives
csdid intake_calls pop, ivar(state) time(mon_num_tot) gvar(gvar) vce(cluster state)
gen sample = e(sample)
tabstat pop if sample ==1, statistics(N mean min max sd min max) by(year) format(%8.0f) 

****************************  ONLINE Legalization - Total Call Results ***************************
clear all
*load data
import excel "/Users/mrjensen/Library/CloudStorage/OneDrive-UniversityofGeorgia/Gambling/Unified Data/Unified_prob_gamb_dataset.xlsx", sheet("online") firstrow

set scheme plotplain

*xtset
xtset state mon_num_tot

*do this because not all states have a data prior to this point
drop if mon_num_tot < 28 

*pop
gen lnpop = ln(pop)

*drop  VA - 22 - Cannonical diff-n-diff cannot handle multiple time points & VA did not provide total call data
drop if state == 22

*drop TX(6), because of missingness
drop if state == 6

*Specific DiD models
xtdidregress (tot_calls) (online_leg), group(fips_state_code) time(mon_num_tot) 
estat ptrends
estat granger
estat trendplot, ltrends title("Total Calls") subtitle("Online Sports Gambling Legalization in TN") xtitle("Month (#)") ytitle("Toal Calls") xlabel(#10) plotregion(lcolor(black) lwidth(medium))

*intakes various states to check senesitivity of results 
*drop various states

/* 
w/ CA + and sig at .10 (CA,KY, KS, ME)
non-significant (CA,KY,KS) 
w/o CA 9.81 and sig at .05 (KY, KS, ME)
(KS ME) ~10 and sig at .10, non-significant - no violations
CA KS non-significant
w/o kansas 7.15 at 0.05 (KY, ME)
non-significant and violations (KY KS)

w/o Maine (just KY) violations everywhere, 
Just CA violations everywhere 
just maine pos and sig but violations everywhere
just KS pos and sig but violations everywhere */

*descriptives
asdoc sum intake_calls tot_calls by fips_state_code, stat(N mean sd min max)
by state: sum intake_calls tot_calls if asample1 == 1 
sum intake_calls if state == 10 & online_leg == 1 
